package com.hoshiicloud.common.constant.enumeration;

/**
 * @author: Mr.wu
 * @descripton: 支付渠道信息枚举类
 * @date: 14:37 2019/5/27
 */
public enum Channel {
    WEIXIN(0,"weixin","微信"),
    ALIPAY(1,"alipay","支付宝");
    private int channel;

    private String payCode;

    private String payName;

    private Channel(int channel,String payCode,String payName){
        this.channel=channel;
        this.payCode=payCode;
        this.payName=payName;
    }
    public int getChannel(){
        return this.channel;
    }

    public String getPayCode() {
        return payCode;
    }

    public String getPayName() {
        return payName;
    }

    public static Channel getByChannel(int channel) {
        for (Channel aparameterStatus : values()) {
            if (aparameterStatus.getChannel() == channel) {
                return aparameterStatus;
            }
        }
        return null;
    }
    public static Channel getByPayCode(String payCode) {
        for (Channel aparameterStatus : values()) {
            if (aparameterStatus.getPayCode().equals(payCode)) {
                return aparameterStatus;
            }
        }
        return null;
    }

    public static String getNameByChannel(int channel) {
        for (Channel aparameterStatus : values()) {
            if (aparameterStatus.getChannel() == channel) {
                return aparameterStatus.getPayName();
            }
        }
        return "";
    }
}
